package form.ui.component.ScrollBar
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import form.ui.core.Button;
	import form.ui.core.FMSprite;

	public class ScrollButton extends Button
	{
		public static const INTERVAL:int = 30;
		public static const MOVE:int = 4;
		
		protected var timer:Timer = new Timer(ScrollButton.INTERVAL);
		
		public function ScrollButton()
		{
			super();
			if(labelField && contains(labelField)) 
			{
				removeChild(labelField);
			}
			this.timer.addEventListener(TimerEvent.TIMER, this.onTimerEvent);
		}
		
		public override function mouseDownAction():void {
			this.resetTimer();
			timer.start();
		}
		
		public override function mouseUpAction():void {
			this.resetTimer();
		}
		
		public function dispatchScrollButtonEvent():void {}
		
		protected function onTimerEvent(e:TimerEvent):void {
			this.dispatchScrollButtonEvent();
		}
		
		protected function resetTimer():void {
			timer.stop();
			timer.reset();
		}
		
		protected override function onMouseOut(e:Event):void {
			super.onMouseOut(e);
			
			this.resetTimer();	
		}
		
		protected override function onAddedToStage(e:Event):void {
			
		}
		override public function get width():Number
		{
			return this.mouseUp ? this.mouseUp.width - 1 : super.width;
		}
	}
}